#pragma once
#include <unistd.h>
#include <fcntl.h>
#include "log.hpp"
#include "errno.hpp"
class Util{
public:
    static void SetNonBlock(int sockfd){
        int OldMode = fcntl(sockfd,F_GETFL);
        if(OldMode == -1){
            logmessage(ERROR,"GetNonBlock faild,code:%d,codestr:%s",errno,strerror(errno));
            return;
        }
        if((fcntl(sockfd, F_SETFL,OldMode|O_NONBLOCK)) == -1 ){
            logmessage(ERROR,"SetNonBlock faild,code:%d,codestr:%s",errno,strerror(errno));
            return;
        }
    }
};